import { ref } from 'vue';

import {useLoginStore} from "@/store/login/login.js";
// src/utils/token.js


export function useToken() {
    let loginStore = useLoginStore();
    function addToken(token) {
        loginStore.token= token
    }

    function removeToken(token) {
        loginStore.token= ""
    }

    function updateToken(oldToken, newToken) {
        const index = tokens.value.indexOf(oldToken);
        if (index !== -1) {
            tokens.value.splice(index, 1, newToken);
        }
    }

    function getToken() {
        return loginStore.token;
    }

    return {
        tokens:loginStore.token,
        addToken,
        removeToken,
        updateToken,
        getToken
    };
}